package com.app.aipass.fragment.my.reward;

import android.util.TimeUtils;

import androidx.annotation.Nullable;

import com.app.aipass.R;
import com.app.aipass.entity.GetRewardEntity;
import com.app.aipass.utils.DoubleUtils;
import com.app.aipass.utils.TimeUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class RewardAdapter extends BaseQuickAdapter<GetRewardEntity.RewardOrdersBean, BaseViewHolder> {

    public RewardAdapter(int layoutResId, @Nullable List<GetRewardEntity.RewardOrdersBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, GetRewardEntity.RewardOrdersBean rewardOrdersBean) {
        holder.setText(R.id.tvAllNum,rewardOrdersBean.getAmount()+"AI");
        holder.setText(R.id.tvOverNum,rewardOrdersBean.getAcc_income()+"AI");
        holder.setText(R.id.tvNotRewardNum,rewardOrdersBean.getNo_release()+"AI");
        holder.setText(R.id.tvEveryDayReward,(DoubleUtils.divide(Double.valueOf(rewardOrdersBean.getAmount()),Double.valueOf(rewardOrdersBean.getIncome_days())))+"AI");
        switch (rewardOrdersBean.getStatus()){
            case 1:
                holder.setText(R.id.tvStatus,"正常");
                break;
            case 2:
                holder.setText(R.id.tvStatus,"到期");
                break;
            case 3:
                holder.setText(R.id.tvStatus,"冻结");
                break;
        }
        holder.setText(R.id.tvOpenTime, TimeUtil.timeStamp2Date(String.valueOf(rewardOrdersBean.getStart_time()),"yyyy-MM-dd"));

        switch (rewardOrdersBean.getP_id()){
//            case 1:
//                holder.setBackgroundRes(R.id.ivLevel,R.mipmap.icon_level_reward_one);
//                holder.setText(R.id.tvLevelNick,"优秀贡献者");
////                holder.setText(R.id.tvLevelName,"（1级雄兵）");
//                break;
            case 2:
                holder.setBackgroundRes(R.id.ivLevel,R.mipmap.icon_level_reward_one);
                holder.setText(R.id.tvLevelNick,"优秀贡献者");
//                holder.setText(R.id.tvLevelName,"（2级雄兵）");
                break;
            case 3:
                holder.setBackgroundRes(R.id.ivLevel,R.mipmap.icon_level_reward_two);
                holder.setText(R.id.tvLevelNick,"精英贡献者");
//                holder.setText(R.id.tvLevelName,"（3级雄兵）");
                break;
            case 4:
                holder.setBackgroundRes(R.id.ivLevel,R.mipmap.icon_level_reward_four);
                holder.setText(R.id.tvLevelNick,"卓越贡献者");
//                holder.setText(R.id.tvLevelName,"（4级雄兵）");
                break;
        }
    }
}
